package com.roc.template.mysql.controller;

import com.roc.template.base.PageBean;
import com.roc.template.mysql.entity.Order;
import com.roc.template.mysql.service.OrderService;
import com.roc.template.mysql.vo.OrderVo;
import com.roc.template.base.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @ClassName OrderController
 * @Description: TODO
 * @Author Administrator
 * @Date 2020/7/20 15 40
 * @Version V1.0
 **/
@Api(description = "mysql基本操作")
@RestController
@RequestMapping("/order")
public class OrderController {

    @Resource
    private OrderService orderService;

    @ApiOperation("查询分页")
    @GetMapping("/list")
    public Result list(OrderVo orderVo) {
        PageBean<Order> orderPageBean = orderService.pageQuery(orderVo);
        return new Result(true, "","",orderPageBean);
    }

    @ApiOperation("新增")
    @PostMapping("/add")
    public Result insert(@RequestBody Order order) {
        orderService.insert(order);
        return new Result(true, "","","");
    }

    @ApiOperation("删除")
    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable String id) {
        orderService.delete(id);
        return new Result(true, "","","");
    }

    @ApiOperation("修改")
    @PostMapping("/update")
    public Result update(@RequestBody Order order){
        orderService.update(order);
        return new Result(true, "","","");
    }

}
